{extend name='public/layout' /}
{block name='content'}
<div class="main">
    <div class="position">
        <p>
            您当前的位置：<a href="{:url('Index/index')}">{$site.title}</a> > <a href="{:url('Question/index')}">问答</a>&gt;{$info.title}
        </p>
    </div>
    <div class="overflow_h m_t_15">
        <div class="body_left">
            <div class="ask_show01">
                <div class="ask_show01_n1">
                    <h2>{$info.title}</h2>
                    <p>提问者：{$info.user_name} | 浏览次数 {$info.hits} 次 | {$info.create_time|date='Y-m-d H:i:s',###}</p>
                </div>
                <div class="ask_show01_n2">
                    <div class="ask_info">
                        {$info.content}
                    </div>
                    {notempty name='house_info'}
                    <div class="ask_house">
                        <span>相关楼盘:</span><a title="{$house_info.title}" href="{:url('Loupan/detail',['id'=>$house_info['id']])}">{$house_info.title}</a>
                    </div>
                    {/notempty}
                    <h2><a href="javascript:;" class="but36 myanswer">我有更好的答案</a></h2>
                    <div id="ask_answer" style="display:none;">
                        <input type="hidden" id="ask_id" value="{$info.id}">
                        <p><textarea class="inp09" name="textarea" id="answer_content" placeholder="请在这输入您要回答的内容" cols="45" rows="5"></textarea></p>
                        <p class="overflow_h"><span class="ask_show01_n2_sp"><a id="answerBut" data-uri="{:url('Ajax/answer')}" href="javascript:;" class="but19">我来回答</a></span></p>
                    </div>
                </div>
            </div>
            <div class="ask_show02">
                <h1>更多网友回答：(共<span class="org">{$moreAnswer->total()}</span>条)</h1>
                {volist name="moreAnswer" id='vo'}
                <div class="ask_show03 overflow_h">
                    <span class="ask_show03_img"><a href="{:url('Store/ask',['uid'=>$vo['user_id']])}" target="_blank"><img alt="{$vo.user.nickname}" src="__IMG__/nopic.jpg" data-original="{$vo.user.headimgurl}" class="lazy" width="52" height="52" /></a></span>
                    <div class="ask_show03_t">
                        <h2><span class="ask_show03_t_s1">{$vo.create_time|date='Y-m-d H:i:s',###}</span>回答者：<strong class="org"><a target="_blank" href="{:url('Store/ask',['uid'=>$vo['user_id']])}">{$vo.user.nickname}</a></strong>{notempty name='vo.user.buy_phone'} | 购房热线：<span class="org"><strong>{$vo.user.buy_phone}</strong></span>{/notempty}</h2>
                        <p>{$vo.content}</p>
                        <p data-bid="{$vo.id}" data-uri="{:url('Ajax/fabulous')}"><span data-boxtype="top" class="ask_show03_t_s2" data-type="good">{$vo.good}</span><span data-boxtype="step" class="ask_show03_t_s3" data-type="bad">{$vo.bad}</span></p>
                    </div>
                </div>
                {/volist}
                <div class="plastic_bottom_pages">
                    {$pages}
                </div>
            </div>
            <div class="ask_show04">
                <h1 class="n_h_title"><span class="s_bg_line">相关问答</span><span class="more"><a href="{:url('Question/index',['cate_id'=>$info['cate_id']])}">更多</a></span></h1>
                <ul>{php}$cate_id=$info['cate_id'];$cityid=$cityInfo['id'];{/php}
                    {fang:lists table='ask' field='id,title' where="status=1 and city=$cityid and cate_id=$cate_id" order='id desc' limit='10' id='vo'}
                    <li><a title="{$vo.title}" href="{:url('Question/detail',['id'=>$vo['id']])}">{$vo.title}</a></li>
                    {/fang:lists}
                </ul>
            </div>
        </div>
        <div class="body_right">
            <form action="{:url('Ajax/question')}" id="form"  method="post">
                <div class="ask_list_r01">
                    <p><input type="text" class="inp07" name="title" id="title" placeholder="请输入标题" /></p>
                    <p><textarea name="content" class="inp08" id="content" placeholder="请在这输入问题详细内容描述"></textarea></p>
                    <p class="overflow_h"><span class="adl_list_sp1">
  <select class="select03" name="cate_id" id="cate_id">
      {volist name='cate["tree"]' id='val'}
      <option value="{$val.id}" {present name="val._child"}disabled{/present}>{$val.name}</option>
      {present name='val._child'}
      {volist name='val._child' id='vo'}
      <option value="{$vo.id}">--{$vo.name}</option>
      {/volist}
      {/present}
      {/volist}
  </select>
</span><span class="adl_list_sp2"><a  href="javascript:;" id="askBut" class="but35">提交问题</a></span></p>
                </div>
            </form>
            <div class="ask_list_r03">
                <h1 class="n_h_title02">
                    <ul id="ask_tab">
                        <li><a href="javascript:;" data-did="new" class="selected">最新问答</a></li>
                        <li><a href="javascript:;" data-did="hits" >热门问答</a></li>
                    </ul><!--span class="more"><a href="#">更多</a></span-->
                </h1>
                <div id="ask_content">
                    <ul class="ul_ask">
                        {fang:lists table='ask' field='id,title' where='status=1' order='id desc' limit='10' id='vo'}
                        <li><a title="{$vo.title}" href="{:url('Question/detail',['id'=>$vo['id']])}">· {$vo.title}</a></li>
                        {/fang:lists}
                    </ul>
                    <ul class="ul_ask" style="display:none;">
                        {fang:lists table='ask' field='id,title' where='status=1' order='hits desc' limit='10' id='vo'}
                        <li><a title="{$vo.title}" href="{:url('Question/detail',['id'=>$vo['id']])}">· {$vo.title}</a></li>
                        {/fang:lists}
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/plugins/jquery.ajax.form.js"></script>
<script>
    $(function(){
        $('.ask_show03_t_s2,.ask_show03_t_s3').bind('click',function(){
            var type = $(this).data('type'),me=$(this),id=$(this).parent().data('bid'),url=$(this).parent().data('uri');
            var param = {id:id,type:type};
            $.post(url,param,function(res){
                if(res.status == 1){
                    layer.msg(res.msg,{icon:1});
                    me.text(parseInt(me.text())+1);
                }else{
                    layer.msg(res.msg,{icon:2});
                }
            });
        });
        $('.myanswer').bind('click',function(){
            $('#ask_answer').toggle();
        });
        $('#answerBut').bind('click',function(){
            var ask_id = $('#ask_id').val(),content=$('#answer_content').val(),url=$(this).data('uri');
            if($.trim(content).length==0){
                layer.msg('请填写答案后再提交');
            }else{
                var param = {ask_id:ask_id,content:content};
                $.post(url,param, function (res) {
                    if(res.status == 1){
                        layer.msg(res.msg,{icon:1});
                        setTimeout(function(){window.location.href=location.href+'?t='+Math.random();},2000);
                    }else{
                        layer.msg(res.msg,{icon:2});
                    }
                })
            }
        });
        $('#askBut').bind('click',function(){
            var title = $('#title').val();
            var content = $('#content').val();
            var cate_id = $('#cate_id').val();
            if(title.length==0){
                layer.msg('请填写标题',{icon:2});
                return false;
            }
            if(content.length==0){
                layer.msg('请填写内容',{icon:2});
                return false;
            }
            if(cate_id==0){
                layer.msg('请选择分类',{icon:2});
                return false;
            }
            $('#form').submit();
        });
        $("#ask_tab li a").bind('click',function(){
            var index = $(this).parent().index();
            $(this).addClass('selected').parent().siblings().find('a').removeClass('selected');
            $('#ask_content').children().eq(index).show().siblings().hide();
        });
        $('#form').ajaxForm({success:complate,dataType:'json'});
        function complate(result){
            if(result.status == 1){
                layer.msg(result.msg,{icon:1});
                setTimeout(function(){
                    window.location.href = location.href + '?t='+Math.random();
                },3000);
            } else {
                layer.msg(result.msg,{icon:2});
            }
        }
    });
</script>
{/block}